import com.bao.mapper.PeopleOrderMapper;
import com.bao.pojo.Order;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import org.junit.Test;

import java.io.IOException;
import java.io.InputStream;
import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: bao
 * Date: 2020/05/28 11:49
 * Description:
 * Version: V1.0
 */
public class PeopleMybatisTest2 {

    @Test
    public void mybatisTest() throws IOException {
        String resource = "mybatis.xml";
        InputStream inputStream = Resources.getResourceAsStream(resource);
        //创建SqlSessionFactory工厂类
        SqlSessionFactory sqlSessionFactory = new SqlSessionFactoryBuilder().build(inputStream);
        //得到SqlSession
        SqlSession sqlSession = sqlSessionFactory.openSession();
        //调用具体Mapper
        PeopleOrderMapper peopleOrderMapper = sqlSession.getMapper(PeopleOrderMapper.class);
        List<Order> order = peopleOrderMapper.selectPeople();
        System.out.println(order);
    }
}
